import React,{useEffect} from 'react'
import{useDispatch,useSelector} from 'react-redux'
import axios from '../../../axioslist/index'
import {LIATDATA,ALLTYPELIST,ONTLIATDATA}  from '../../../types/index.d'
import '../../../api/index'


export default function Index() {
    const dispatch = useDispatch()

    useEffect(()=>{
        axios.get('/api/list').then(res=>{
            dispatch({  //派发给仓库
                // ONTLIATDATA  是定义的校验的变
                type:ONTLIATDATA,
                payload:res.data.list
            })
        })
    },[])
    //接受数据
    const listdata = useSelector((state:ALLTYPELIST)=>{
        return state.list
    })
    console.log(listdata,'111');
    

  return (
    <div>
        {
            listdata.map((item,index)=>{
                return <p key={index}>

                    <img src={item.img} alt="" />
                    <p>{item.user}</p>
                    
                    </p>
            })
        }
    </div>
  )
}
